<?php if (!defined('THINK_PATH')) exit();?><style>
    .form-group label{width:85px}
</style>
<section class="content" >
    <div class="row">
        <div class="col-md-12">
            <div class="box box-danger">
                <div class="box-body">
                    <form id="site_public_editinfo_form">
                        <input type="hidden" name="id" value="<?php echo ($info["id"]); ?>" />
                        <div class="form-group">
                            <label style="display:inline-table">手机
                                <i class="fa fa-pencil-square-o"></i>:</label>
                            <input type="text" placeholder="请输入手机号码" 
                                   class="form-control"  data-validation="length"
                                   data-validation-length="min1"
                                   name="mobile" value="<?php echo ($info["mobile"]); ?>"
                                   data-validation-error-msg="请输入正确手机号码"
                                   style="display:inline;width: 70%">
                        </div>
                        <div class="form-group">
                            <label style="display:inline-table">联系人
                                <i class="fa fa-pencil-square-o"></i>:</label>
                            <input type="text" placeholder="请输入联系人"
                                   class="form-control"
                                   name="linkman" value="<?php echo ($info["linkman"]); ?>"
                                   style="display:inline;width: 70%">
                        </div>
                        <!--<div class="form-group">-->
                            <!--<label style="display:inline-table">登录密码-->
                                <!--<i class="fa fa-pencil-square-o"></i>:</label>-->
                            <!--<input type="text" placeholder="请输入登录密码"-->
                                   <!--class="form-control"  data-validation="length"-->
                                   <!--data-validation-length="min1"-->
                                   <!--name="password" value="<?php echo ($info["password"]); ?>"-->
                                   <!--data-validation-error-msg="请输入登录密码"-->
                                   <!--style="display:inline;width: 70%">-->
                        <!--</div>-->
                        <div class="form-group">
                            <label style="display:inline-table">站点名称
                                <i class="fa fa-pencil-square-o"></i>:</label>
                            <input type="text" placeholder="请输入站点名称"
                                   class="form-control"  data-validation="length"
                                   data-validation-length="min1"
                                   name="name" value="<?php echo ($info["name"]); ?>"
                                   data-validation-error-msg="请输入站点名称"
                                   style="display:inline;width: 70%">
                        </div>
                        <div class="form-group">
                            <label style="display:inline-table">地址
                                <i class="fa fa-pencil-square-o"></i>:</label>
                            <input type="text" placeholder="请输入地址"
                                   id="address"
                                   class="form-control"  data-validation="length"
                                   data-validation-length="min1"
                                   name="address" value="<?php echo ($info["address"]); ?>"
                                   data-validation-error-msg="请输入地址"
                                   style="display:inline;width: 70%">
                        </div>
                        <div class="form-group">
                            <label>经纬度：</label>
                            <input id="lonlat" name="lonlat"  class="form-control" style="display:inline;width: 70%"
                                   value="<?php echo ((isset($info["longitude"]) && ($info["longitude"] !== ""))?($info["longitude"]):0); ?>,<?php echo ((isset($info["latitude"]) && ($info["latitude"] !== ""))?($info["latitude"]):0); ?>" readonly onclick="getLonlat()" />
                        </div>
                        <div class="form-group">
                            <label style="display:inline-table">状态
                                <i class="fa fa-pencil-square-o"></i>:</label>
                            <label>
                                <input type="radio" value="0" name="status"
                                <?php if(($info['status']) == "0"): ?>checked="checked"<?php endif; ?>
                                <?php if(($info['status']) == ""): ?>checked="checked"<?php endif; ?>
                                >&nbsp;&nbsp;启用
                            </label>
                            <label>
                                <input type="radio" value="1" name="status"
                                <?php if(($info['status']) == "1"): ?>checked="checked"<?php endif; ?>
                                >&nbsp;&nbsp;停用
                            </label>
                        </div>
                        <div class="form-group">
                        <label style="display:inline-table">装料口数量:</label>
                        <input type="text" placeholder="请输入装料口数量"
                               class="form-control"  data-validation="number"
                               name="load_num" value="<?php echo ($info["load_num"]); ?>"
                               data-validation-error-msg="请输入装料口数量"
                               style="display:inline;width: 70%">
                        </div>

                        <div class="box-footer">
                            <span class="input-group-btn">
                                <button class="btn btn-danger pull-left" type="button"  id="close-dialog">取消</button>
                                <button class="btn btn-primary pull-right" type="button" id='site_public_editinfo_form_submit'>提交</button>
                            </span>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $(function () {
            $(".select2").select2();
            $('#site_public_editinfo_form_submit').click(function () {
                $('#site_public_editinfo_form').submit();
            });
            $.validate({
                onSuccess: function () {
                    publicEditinfoFormSubmit();
                    return false;
                }
            });
        });

        function publicEditinfoFormSubmit() {
            $.post("<?php echo U('Site/add');?>",
                    $("#site_public_editinfo_form").serialize(), function (res) {
                if (!res.status) {
                    $.messager.alert('提示信息', res.info, 'error');
                } else {
                    $.messager.alert('提示信息', res.info, 'info');
                    dialog.get('dialogPage').close().remove();
                    siteTable.fnDraw(false);
                }
            });

            return false;
        }
        var map = null;
        function getLonlat(){
            var lonlat = $("#lonlat").val();
            var lons = lonlat.split(',');
            var url = '<?php echo U("Site/getLonlat");?>?lng='+lons[0]+"&lat="+lons[1]+"&address="+$('#address').val();
            $.dialog(url, '站点位置', null,46,'getLonlat');
        }
    </script>
</section>